package com.ctbri.gui;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;

import javax.swing.JButton;
import javax.swing.JFrame;

import com.ctbri.util.SwingConsole;

public class Ex11 extends JButton {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Random rand = new Random();
	public Ex11() {
		init();
	}
	public Ex11(String label) {
		super(label);
		init();
	}
	private void init(){
		addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				((JButton)e.getSource()).setBackground(new Color(rand.nextInt(0xFFFFFF)));
			}
		});
	}
	
	public static void main(String[] args) {
		JFrame f = new JFrame();
		Ex11 button = new Ex11("button");
		f.add(button);
		SwingConsole.run(f, 100, 100);
	}

}
